<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class FmwEzrController extends Controller
{
    protected $baseUrl = '/api/ezr/api/';
    protected $shopCode = 'ezr01';

    public function index(Request $request)
    {
        $apiName = str_replace($this->baseUrl, '', $request->getRequestUri());
        list($m1, $m2) = explode('/', $apiName);
        $method = sprintf("%s_%s", lcfirst($m1), lcfirst($m2));

        if (!method_exists($this, $method)) {
            echo sprintf("[%s] mock function not exists", $method);
            exit;
        }

        return $this->$method($request);
    }

    public function mProd_prodDown(Request $request)
    {
        $args = json_decode($request->get('Args'), true);
        $page = $args['pageIndex'] ?? 1;

        $product1 = [
            "ItemName" => "EZR男卫衣",
            "ProdOrigin" => "EZR",
            "PfCategoryName" => "男装",
            "IsStatus" => true,
            "CreateDate" => "2023/11/7 17:06:10",
            "LastModifiedDate" => "2023/11/7 17:06:15",
            "RetailPrice" => 120,
            "SalePrice" => 100,
            "ItemNo" => "EZRMC001",
            "PictureUrl" => "",
            "ExtraPicList" => [],
            "IsOnSale" => false,
            "DicCategorys" => [],
            "H5Url" => "",
            "DetailPageUrl" => "",
            "ProdAttrs" => "",
            "Id" => "29001",
            "Dtls" => [
                [
                    "BarCode" => "EZRMC00101",
                    "OutCode" => "EZRSKUA01",
                    "Stocks" => 100,
                    "ItemNo" => "EZRMC001",
                    "ItemName" => "EZR男卫衣",
                    "CategoryName" => "男装",
                    "CreateDate" => "2023/11/7 17:24:18",
                    "LastModifiedDate" => "2023/11/7 17:24:20",
                    "RetailPrice" => 120,
                    "SalePrice" => 100,
                    "Id" => "2900101",
                    "SkuPicUrl" => "",
                    "SkuAttrVals" => [
                        ["SpecName" => "颜色", "SpecValue" => "红色"],
                        ["SpecName" => "尺码", "SpecValue" => "38"],
                    ],
                ],
                [
                    "BarCode" => "EZRMC00102",
                    "OutCode" => "EZRSKUA02",
                    "Stocks" => 100,
                    "ItemNo" => "EZRMC001",
                    "ItemName" => "EZR男卫衣",
                    "CategoryName" => "男装",
                    "CreateDate" => "2023/11/7 17:24:18",
                    "LastModifiedDate" => "2023/11/7 17:24:20",
                    "RetailPrice" => 120,
                    "SalePrice" => 100,
                    "Id" => "2900102",
                    "SkuPicUrl" => "",
                    "SkuAttrVals" => [
                        ["SpecName" => "颜色", "SpecValue" => "绿色"],
                        ["SpecName" => "尺码", "SpecValue" => "38"],
                    ],
                ],
                [
                    "BarCode" => "EZRMC00103",
                    "OutCode" => "EZRSKUA03",
                    "Stocks" => 100,
                    "ItemNo" => "EZRMC001",
                    "ItemName" => "EZR男卫衣",
                    "CategoryName" => "男装",
                    "CreateDate" => "2023/11/7 17:24:18",
                    "LastModifiedDate" => "2023/11/7 17:24:20",
                    "RetailPrice" => 120,
                    "SalePrice" => 100,
                    "Id" => "2900103",
                    "SkuPicUrl" => "",
                    "SkuAttrVals" => [
                        ["SpecName" => "颜色", "SpecValue" => "黄色"],
                        ["SpecName" => "尺码", "SpecValue" => "40"],
                    ],
                ],
            ],
        ];
        $product2 = [
            "ItemName" => "EZR女卫衣",
            "ProdOrigin" => "EZR",
            "PfCategoryName" => "女装",
            "IsStatus" => true,
            "CreateDate" => "2023/11/7 17:06:10",
            "LastModifiedDate" => "2023/11/7 17:06:15",
            "RetailPrice" => 60,
            "SalePrice" => 50,
            "ItemNo" => "EZRMC002",
            "PictureUrl" => "",
            "ExtraPicList" => [],
            "IsOnSale" => false,
            "DicCategorys" => [],
            "H5Url" => "",
            "DetailPageUrl" => "",
            "ProdAttrs" => "",
            "Id" => "29002",
            "Dtls" => [
                [
                    "BarCode" => "EZRMC00201",
                    "OutCode" => "EZRSKUB01",
                    "Stocks" => 100,
                    "ItemNo" => "EZRMC002",
                    "ItemName" => "EZR女卫衣",
                    "CategoryName" => "女装",
                    "CreateDate" => "2023/11/7 17:24:18",
                    "LastModifiedDate" => "2023/11/7 17:24:20",
                    "RetailPrice" => 60,
                    "SalePrice" => 50,
                    "Id" => "2900201",
                    "SkuPicUrl" => "",
                    "SkuAttrVals" => [
                        ["SpecName" => "颜色", "SpecValue" => "红色"],
                        ["SpecName" => "尺码", "SpecValue" => "36"],
                    ],
                ],
            ],
        ];

        $result = [];
        if ($page == 1) {
            $result[] = $product1;
            $result[] = $product2;
        }

        return [
            'Status' => true,
            'StatusCode' => 200,
            'Sign' => 'XXXXXXXXXX',
            'Timestamp' => (string)time(),
            'Msg' => '成功',
            'Result' => $result,
            'PageCount' => 1
        ];
    }

    public function warehouse_prdsearch(Request $request)
    {
        $args = json_decode($request->get('Args'), true);
        $page = $args['PageIndex'] ?? 1;

        $sku1 = ['BarCode' => 'EZRMC00101'];
        $sku2 = ['BarCode' => 'EZRMC00102'];
        $sku3 = ['BarCode' => 'EZRMC00103'];
        $sku4 = ['BarCode' => 'EZRMC00201'];

        $result = [];
        if ($page == 1) {
            $result[] = $sku1;
            $result[] = $sku2;
            $result[] = $sku3;
            $result[] = $sku4;
        }

        return [
            'Status' => true,
            'StatusCode' => 200,
            'Sign' => 'XXXXXXXXXX',
            'Timestamp' => (string)time(),
            'Msg' => '成功',
            'Result' => $result,
            'PageCount' => 1
        ];
    }

    public function morder_ordgetone(Request $request)
    {
        $args = json_decode($request->get('Args'), true);
        $reqOrderSn = $args['OrderCode'] ?? '';

        $orderSn = 'E6306202405300001';
        $isExchange = false;
        $returnSn = 'T630620240530000101';
        $originalOrderSn = 'E6306202405300001';
        $itemTwoQty = false;

        if ($reqOrderSn != $orderSn) {
            return [
                'Status' => true,
                'StatusCode' => 200,
                'Sign' => 'XXXXXXXXXX',
                'Timestamp' => (string)time(),
                'Msg' => '成功',
                'Result' => []
            ];
        }

        $order = [
            "Code" => $orderSn,
            "OrderType" => "MALL",
            "TotalQty" => 2,
            "TotalMoney" => $itemTwoQty ? 250 : 150,
            "DiscountMoney" => 0,
            "DiscountAmount" => 0,
            "ReturnQuantity" => 0,
            "ReturnMoney" => 0,
            "OrderTime" => "2024-05-30 16:07:12",
            "OrderPreShipTime" => "",
            "IsPayed" => true,
            "PayTime" => "2024-05-30 16:07:18",
            "HasSendTime" => "",
            "FinishTime" => "",
            "PayAmount" => $itemTwoQty ? 250 : 150,
            "UseCouponNo" => "",
            "UseCouponValue" => 0,
            "RewardFee" => 0,
            "UseBonus" => 0,
            "ExpressCode" => "",
            "ExpressOrgCode" => "",
            "ExpressOrgName" => "",
            "ExpressFee" => 0,
            "ExpressFeeType" => "MY",
            "ExpressCost" => 0,
            "IsCod" => false,
            "CodServiceFee" => 0,
            "BuyerCode" => "zh001ezr",
            "BuyerOldCode" => "zh001oldezr",
            "BuyerEmail" => "",
            "BuyerNick" => "zh",
            "RecvConsignee" => "张恒",
            "RecvMobile" => "16601166306",
            "RecvMobileCountryCode" => "",
            "RecvTel" => "",
            "RecvAddress" => "双井北汽资产大厦5楼",
            "RecvProvince" => "北京市",
            "RecvCity" => "北京市",
            "RecvCounty" => "朝阳区",
            "OrderStatus" => 2,
            //"OrderStatus" => 4,
            "BuyerRemark" => "尽快发货",
            "OrderRemark" => "",
            "ShopCode" => $this->shopCode,
            "StoreCode" => "EZRBJ001",
            "ServiceSalerCode" => "",
            "ServiceSalerName" => "",
            "ServiceChannelCode" => "",
            "SellerSysShopCode" => "",
            "SellerCode" => "",
            "DelivTypeDesc" => "快递",
            "DelivType" => 0,
            "Dtls" => [
                [
                    "Id" => (int)(preg_replace("/[^0-9]/", '', $orderSn) . '01'),
                    "ItemNo" => "EZRMC001",
                    "BarCode" => "EZRMC00101",
                    "ProductName" => "EZR男卫衣",
                    "PriceOriginal" => 100,
                    "PriceSell" => 100,
                    "Quantity" => $itemTwoQty ? 2 : 1,
                    "Amount" => $itemTwoQty ? 200 : 100,
                    "DiscountMoney" => 0,
                    "AlipayCashVoucherAmount" => 0,
                    "DiscountAmount" => 0,
                    "FrDiscountAmount" => 0,
                    "CouponDiscountAmount" => 0,
                    "RewardFee" => 0,
                    "UseBonus" => 0,
                    "UseIntegralMoney" => 0,
                    "UseCouponNo" => "",
                    "UseCouponValue" => 0,
                    "IsGift" => false,
                    "GiftType" => "",
                    "ReturnQuantity" => 0,
                    "ReturnPrice" => 0,
                    "ReturnMoney" => 0,
                    "RetailPrice" => 120,
                    "OutOrderCode" => "",
                    "OutOrderCodeExt1" => "",
                    "SkuAttrValsEx" => "",
                    "OrderCouponAmount" => 0,
                    "ProCouponAmount" => 0,
                    "AvgAmount" => $itemTwoQty ? 200 : 100,
                    "OutCode" => "EZRSKUA01",
                    "WxProCouponAmount" => 0,
                    "WxOrderCouponAmount" => 0,
                    "DeliverQuantity" => 0,
                    "RefundQuantity" => 0,
                    "FxType" => -1,
                    "SgCode" => "",
                    "SgShopCode" => "",
                    "VipCode" => "",
                    "RelationType" => -1,
                    "ProductBrandId" => 0,
                    "ProductBrandCode" => "",
                    "FxOrderRateInfos" => [],
                    "AttrInfos" => null,
                    "SkuActType" => 0,
                    "VipDiscountAmount" => 0,
                    "ChangeDiscountAmount" => 0,
                    "TimelimitedDiscountAmount" => 0,
                    "ProductContentUrl" => "",
                    "CostPrice" => 0,
                    "ProdType" => 0,
                    "ShipType" => 0,
                    "OrderWipeZeroAmount" => 0,
                ],
                [
                    "Id" => (int)(preg_replace("/[^0-9]/", '', $orderSn) . '02'),
                    "ItemNo" => "EZRMC002",
                    "BarCode" => "EZRMC00201",
                    "ProductName" => "EZR女卫衣",
                    "PriceOriginal" => 50,
                    "PriceSell" => 50,
                    "Quantity" => 1,
                    "Amount" => 50,
                    "DiscountMoney" => 0,
                    "AlipayCashVoucherAmount" => 0,
                    "DiscountAmount" => 0,
                    "FrDiscountAmount" => 0,
                    "CouponDiscountAmount" => 0,
                    "RewardFee" => 0,
                    "UseBonus" => 0,
                    "UseIntegralMoney" => 0,
                    "UseCouponNo" => "",
                    "UseCouponValue" => 0,
                    "IsGift" => false,
                    "GiftType" => "",
                    "ReturnQuantity" => 0,
                    "ReturnPrice" => 0,
                    "ReturnMoney" => 0,
                    "RetailPrice" => 60,
                    "OutOrderCode" => "",
                    "OutOrderCodeExt1" => "",
                    "SkuAttrValsEx" => "",
                    "OrderCouponAmount" => 0,
                    "ProCouponAmount" => 0,
                    "AvgAmount" => 50,
                    "OutCode" => "EZRSKUB01",
                    "WxProCouponAmount" => 0,
                    "WxOrderCouponAmount" => 0,
                    "DeliverQuantity" => 0,
                    "RefundQuantity" => 0,
                    "FxType" => -1,
                    "SgCode" => "",
                    "SgShopCode" => "",
                    "VipCode" => "",
                    "RelationType" => -1,
                    "ProductBrandId" => 0,
                    "ProductBrandCode" => "",
                    "FxOrderRateInfos" => [],
                    "AttrInfos" => null,
                    "SkuActType" => 0,
                    "VipDiscountAmount" => 0,
                    "ChangeDiscountAmount" => 0,
                    "TimelimitedDiscountAmount" => 0,
                    "ProductContentUrl" => "",
                    "CostPrice" => 0,
                    "ProdType" => 0,
                    "ShipType" => 0,
                    "OrderWipeZeroAmount" => 0,
                ],
            ],
            "fxComResList" => [],
            "VipCode" => "zh00101ezr",
            "SelfFetchShopId" => 0,
            "SelfFetchShopCode" => "",
            "DeliveryCode" => "",
            "FxHandler" => 1,
            "BuyerName" => "张恒",
            "BuyerIdCard" => "",
            "Rate" => "",
            "WxPayRequest" => "",
            "WxPayResponse" => "",
            "TradeNo" => "4200000001202405301607188001",
            "CommissionType" => -1,
            "UseCouponNoList" => [],
            "RecvProvinceCode" => "",
            "RecvCityCode" => "",
            "RecvCountyCode" => "",
            "LiveId" => 0,
            "LiveName" => "",
            "LastModify" => "2024-05-30 16:07:20",
            "OrderTag" => $isExchange ? "1" : "",
            "ExchangeRefCode" => $isExchange ? [$originalOrderSn] : [],
            "RelExchangeReturnCode" => $isExchange ? $returnSn : "",
            "IsValetOrd" => "",
            "IsNotPayFinalCancelPre" => false,
        ];

        if ($isExchange) {
            $order['TotalQty'] = 1;
            $order['TotalMoney'] = 0;
            $order['PayAmount'] = 0;
            $order['Dtls'] = [[
                "Id" => (int)(preg_replace("/[^0-9]/", '', $orderSn) . '03'),
                "ItemNo" => "EZRMC001",
                "BarCode" => "EZRMC00103",
                "ProductName" => "EZR男卫衣",
                "PriceOriginal" => 0,
                "PriceSell" => 0,
                "Quantity" => 1,
                "Amount" => 0,
                "DiscountMoney" => 0,
                "AlipayCashVoucherAmount" => 0,
                "DiscountAmount" => 0,
                "FrDiscountAmount" => 0,
                "CouponDiscountAmount" => 0,
                "RewardFee" => 0,
                "UseBonus" => 0,
                "UseIntegralMoney" => 0,
                "UseCouponNo" => "",
                "UseCouponValue" => 0,
                "IsGift" => false,
                "GiftType" => "",
                "ReturnQuantity" => 0,
                "ReturnPrice" => 0,
                "ReturnMoney" => 0,
                "RetailPrice" => 120,
                "OutOrderCode" => "",
                "OutOrderCodeExt1" => "",
                "SkuAttrValsEx" => "",
                "OrderCouponAmount" => 0,
                "ProCouponAmount" => 0,
                "AvgAmount" => 0,
                "OutCode" => "EZRSKUA03",
                "WxProCouponAmount" => 0,
                "WxOrderCouponAmount" => 0,
                "DeliverQuantity" => 0,
                "RefundQuantity" => 0,
                "FxType" => -1,
                "SgCode" => "",
                "SgShopCode" => "",
                "VipCode" => "",
                "RelationType" => -1,
                "ProductBrandId" => 0,
                "ProductBrandCode" => "",
                "FxOrderRateInfos" => [],
                "AttrInfos" => null,
                "SkuActType" => 0,
                "VipDiscountAmount" => 0,
                "ChangeDiscountAmount" => 0,
                "TimelimitedDiscountAmount" => 0,
                "ProductContentUrl" => "",
                "CostPrice" => 0,
                "ProdType" => 0,
                "ShipType" => 0,
                "OrderWipeZeroAmount" => 0,
            ]];
        }

        return [
            'Status' => true,
            'StatusCode' => 200,
            'Sign' => 'XXXXXXXXXX',
            'Timestamp' => (string)time(),
            'Msg' => '成功',
            'Result' => $order
        ];
    }

    public function morder_ordgetbatch(Request $request)
    {
        $args = json_decode($request->get('Args'), true);
        $page = $args['PageIndex'] ?? 1;

        $orderSn1 = 'E6306202405300001';
        $isExchange = false;
        $returnSn1 = 'T630620240530000101';
        $originalOrderSn1 = 'E6306202405300001';
        $itemTwoQty = true;

        $order1 = [
            "Code" => $orderSn1,
            "OrderType" => "MALL",
            "TotalQty" => 2,
            "TotalMoney" => $itemTwoQty ? 250 : 150,
            "DiscountMoney" => 0,
            "DiscountAmount" => 0,
            "ReturnQuantity" => 0,
            "ReturnMoney" => 0,
            "OrderTime" => "2024-05-30 16:07:12",
            "OrderPreShipTime" => "",
            "IsPayed" => true,
            "PayTime" => "2024-05-30 16:07:18",
            "HasSendTime" => "",
            "FinishTime" => "",
            "PayAmount" => $itemTwoQty ? 250 : 150,
            "UseCouponNo" => "",
            "UseCouponValue" => 0,
            "RewardFee" => 0,
            "UseBonus" => 0,
            "ExpressCode" => "",
            "ExpressOrgCode" => "",
            "ExpressOrgName" => "",
            "ExpressFee" => 0,
            "ExpressFeeType" => "MY",
            "ExpressCost" => 0,
            "IsCod" => false,
            "CodServiceFee" => 0,
            "BuyerCode" => "zh001ezr",
            "BuyerOldCode" => "zh001oldezr",
            "BuyerEmail" => "",
            "BuyerNick" => "zh",
            "RecvConsignee" => "张恒",
            "RecvMobile" => "16601166306",
            "RecvMobileCountryCode" => "",
            "RecvTel" => "",
            "RecvAddress" => "双井北汽资产大厦5楼",
            "RecvProvince" => "北京市",
            "RecvCity" => "北京市",
            "RecvCounty" => "朝阳区",
            "OrderStatus" => 2,
            //"OrderStatus" => 4,
            "BuyerRemark" => "尽快发货",
            "OrderRemark" => "",
            "ShopCode" => $this->shopCode,
            "StoreCode" => "EZRBJ001",
            "ServiceSalerCode" => "",
            "ServiceSalerName" => "",
            "ServiceChannelCode" => "",
            "SellerSysShopCode" => "",
            "SellerCode" => "",
            "DelivTypeDesc" => "快递",
            "DelivType" => 0,
            "Dtls" => [
                [
                    "Id" => (int)(preg_replace("/[^0-9]/", '', $orderSn1) . '01'),
                    "ItemNo" => "EZRMC001",
                    "BarCode" => "EZRMC00101",
                    "ProductName" => "EZR男卫衣",
                    "PriceOriginal" => 100,
                    "PriceSell" => 100,
                    "Quantity" => $itemTwoQty ? 2 : 1,
                    "Amount" => $itemTwoQty ? 200 : 100,
                    "DiscountMoney" => 0,
                    "AlipayCashVoucherAmount" => 0,
                    "DiscountAmount" => 0,
                    "FrDiscountAmount" => 0,
                    "CouponDiscountAmount" => 0,
                    "RewardFee" => 0,
                    "UseBonus" => 0,
                    "UseIntegralMoney" => 0,
                    "UseCouponNo" => "",
                    "UseCouponValue" => 0,
                    "IsGift" => false,
                    "GiftType" => "",
                    "ReturnQuantity" => 0,
                    "ReturnPrice" => 0,
                    "ReturnMoney" => 0,
                    "RetailPrice" => 120,
                    "OutOrderCode" => "",
                    "OutOrderCodeExt1" => "",
                    "SkuAttrValsEx" => "",
                    "OrderCouponAmount" => 0,
                    "ProCouponAmount" => 0,
                    "AvgAmount" => $itemTwoQty ? 200 : 100,
                    "OutCode" => "EZRSKUA01",
                    "WxProCouponAmount" => 0,
                    "WxOrderCouponAmount" => 0,
                    "DeliverQuantity" => 0,
                    "RefundQuantity" => 0,
                    "FxType" => -1,
                    "SgCode" => "",
                    "SgShopCode" => "",
                    "VipCode" => "",
                    "RelationType" => -1,
                    "ProductBrandId" => 0,
                    "ProductBrandCode" => "",
                    "FxOrderRateInfos" => [],
                    "AttrInfos" => null,
                    "SkuActType" => 0,
                    "VipDiscountAmount" => 0,
                    "ChangeDiscountAmount" => 0,
                    "TimelimitedDiscountAmount" => 0,
                    "ProductContentUrl" => "",
                    "CostPrice" => 0,
                    "ProdType" => 0,
                    "ShipType" => 0,
                    "OrderWipeZeroAmount" => 0,
                ],
                [
                    "Id" => (int)(preg_replace("/[^0-9]/", '', $orderSn1) . '02'),
                    "ItemNo" => "EZRMC002",
                    "BarCode" => "EZRMC00201",
                    "ProductName" => "EZR女卫衣",
                    "PriceOriginal" => 50,
                    "PriceSell" => 50,
                    "Quantity" => 1,
                    "Amount" => 50,
                    "DiscountMoney" => 0,
                    "AlipayCashVoucherAmount" => 0,
                    "DiscountAmount" => 0,
                    "FrDiscountAmount" => 0,
                    "CouponDiscountAmount" => 0,
                    "RewardFee" => 0,
                    "UseBonus" => 0,
                    "UseIntegralMoney" => 0,
                    "UseCouponNo" => "",
                    "UseCouponValue" => 0,
                    "IsGift" => false,
                    "GiftType" => "",
                    "ReturnQuantity" => 0,
                    "ReturnPrice" => 0,
                    "ReturnMoney" => 0,
                    "RetailPrice" => 60,
                    "OutOrderCode" => "",
                    "OutOrderCodeExt1" => "",
                    "SkuAttrValsEx" => "",
                    "OrderCouponAmount" => 0,
                    "ProCouponAmount" => 0,
                    "AvgAmount" => 50,
                    "OutCode" => "EZRSKUB01",
                    "WxProCouponAmount" => 0,
                    "WxOrderCouponAmount" => 0,
                    "DeliverQuantity" => 0,
                    "RefundQuantity" => 0,
                    "FxType" => -1,
                    "SgCode" => "",
                    "SgShopCode" => "",
                    "VipCode" => "",
                    "RelationType" => -1,
                    "ProductBrandId" => 0,
                    "ProductBrandCode" => "",
                    "FxOrderRateInfos" => [],
                    "AttrInfos" => null,
                    "SkuActType" => 0,
                    "VipDiscountAmount" => 0,
                    "ChangeDiscountAmount" => 0,
                    "TimelimitedDiscountAmount" => 0,
                    "ProductContentUrl" => "",
                    "CostPrice" => 0,
                    "ProdType" => 0,
                    "ShipType" => 0,
                    "OrderWipeZeroAmount" => 0,
                ],
            ],
            "fxComResList" => [],
            "VipCode" => "zh00101ezr",
            "SelfFetchShopId" => 0,
            "SelfFetchShopCode" => "",
            "DeliveryCode" => "",
            "FxHandler" => 1,
            "BuyerName" => "张恒",
            "BuyerIdCard" => "",
            "Rate" => "",
            "WxPayRequest" => "",
            "WxPayResponse" => "",
            "TradeNo" => "4200000001202405301607188001",
            "CommissionType" => -1,
            "UseCouponNoList" => [],
            "RecvProvinceCode" => "",
            "RecvCityCode" => "",
            "RecvCountyCode" => "",
            "LiveId" => 0,
            "LiveName" => "",
            "LastModify" => "2024-05-30 16:07:20",
            "OrderTag" => $isExchange ? "1" : "",
            "ExchangeRefCode" => $isExchange ? [$originalOrderSn1] : [],
            "RelExchangeReturnCode" => $isExchange ? $returnSn1 : "",
            "IsValetOrd" => "",
            "IsNotPayFinalCancelPre" => false,
        ];

        if ($isExchange) {
            $order1['TotalQty'] = 1;
            $order1['TotalMoney'] = 0;
            $order1['PayAmount'] = 0;
            $order1['Dtls'] = [[
                "Id" => (int)(preg_replace("/[^0-9]/", '', $orderSn1) . '03'),
                "ItemNo" => "EZRMC001",
                "BarCode" => "EZRMC00103",
                "ProductName" => "EZR男卫衣",
                "PriceOriginal" => 0,
                "PriceSell" => 0,
                "Quantity" => 1,
                "Amount" => 0,
                "DiscountMoney" => 0,
                "AlipayCashVoucherAmount" => 0,
                "DiscountAmount" => 0,
                "FrDiscountAmount" => 0,
                "CouponDiscountAmount" => 0,
                "RewardFee" => 0,
                "UseBonus" => 0,
                "UseIntegralMoney" => 0,
                "UseCouponNo" => "",
                "UseCouponValue" => 0,
                "IsGift" => false,
                "GiftType" => "",
                "ReturnQuantity" => 0,
                "ReturnPrice" => 0,
                "ReturnMoney" => 0,
                "RetailPrice" => 120,
                "OutOrderCode" => "",
                "OutOrderCodeExt1" => "",
                "SkuAttrValsEx" => "",
                "OrderCouponAmount" => 0,
                "ProCouponAmount" => 0,
                "AvgAmount" => 0,
                "OutCode" => "EZRSKUA03",
                "WxProCouponAmount" => 0,
                "WxOrderCouponAmount" => 0,
                "DeliverQuantity" => 0,
                "RefundQuantity" => 0,
                "FxType" => -1,
                "SgCode" => "",
                "SgShopCode" => "",
                "VipCode" => "",
                "RelationType" => -1,
                "ProductBrandId" => 0,
                "ProductBrandCode" => "",
                "FxOrderRateInfos" => [],
                "AttrInfos" => null,
                "SkuActType" => 0,
                "VipDiscountAmount" => 0,
                "ChangeDiscountAmount" => 0,
                "TimelimitedDiscountAmount" => 0,
                "ProductContentUrl" => "",
                "CostPrice" => 0,
                "ProdType" => 0,
                "ShipType" => 0,
                "OrderWipeZeroAmount" => 0,
            ]];
        }

        $result = [];
        if ($page == 1) {
            $result[] = $order1;
        }

        return [
            'Status' => true,
            'StatusCode' => 200,
            'Sign' => 'XXXXXXXXXX',
            'Timestamp' => (string)time(),
            'Msg' => '成功',
            'Result' => $result,
            'PageCount' => 1
        ];
    }

    public function morder_getorderref(Request $request)
    {
        $args = json_decode($request->get('Args'), true);
        $reqRefundSn = $args['RefundCode'] ?? '';

        $refundSn = 'K630620240530000101';
        $orderSn = 'E6306202405300001';
        $returnSn = 'T630620240530000101';
        $itemTwoQty = true;

        if ($reqRefundSn != $refundSn) {
            return [
                'Status' => true,
                'StatusCode' => 200,
                'Sign' => 'XXXXXXXXXX',
                'Timestamp' => (string)time(),
                'Msg' => '成功',
                'Result' => []
            ];
        }

        $refund = [
            "RefundCode" => $refundSn,
            "RefundStatus" => 1,
            //"RefundStatus" => 2,
            "OrderCode" => $orderSn,
            "ReturnCode" => "",
            //"ReturnCode" => $returnSn,
            "ShopCode" => $this->shopCode,
            "RefundTime" => "2024-05-30 18:50:28",
            "RefundMoney" => 100,
            "AmountMoney" => 100,
            "RefundReason" => "无理由退款",
            "BuyerCode" => "zh001ezr",
            "BuyerNick" => "zh",
            "BuyerOldCode" => "zh001oldezr",
            "BuyerName" => "张恒",
            "BuyerMobile" => "16601166306",
            "RecvConsignee" => "张恒",
            "RecvMobile" => "16601166306",
            "TradeNo" => "4200000001202405301850289001",
            "RefundRemark" => "退款吧",
            "FxHandler" => 1,
            "RefType" => 0,
            //"RefType" => 1,
            //"RefType" => 2,
            "ORfDtls" => [
                [
                    "OrderDtlId" => (int)(preg_replace("/[^0-9]/", '', $orderSn) . '01'),
                    "BarCode" => "EZRMC00101",
                    "OrderQuantity" => $itemTwoQty ? 2 : 1,
                    "PriceOriginal" => 100,
                    "PriceSell" => 100,
                    "AvgAmount" => $itemTwoQty ? 200 : 100,
                    "ItemName" => "EZR男卫衣",
                    "OutOrderCode" => "",
                    "SkuAttrValsEx" => "",
                    "ReturnQuantity" => 1,
                    "ReturnMoney" => 100,
                    "AmountMenory" => 100,
                    "RefundRealAmountMoney" => 100,
                    "AttrInfos" => null,
                    "RefundRealUnitPrice" => 100,
                    "ItemNo" => "EZRMC001",
                    "ItemId" => 29001,
                    "SkuId" => 2900101,
                    "OutCode" => "EZRSKUA01",
                    "Quantity" => 1,
                    "RetailPrice" => 120,
                ],
            ],
            "LastModify" => "2024-05-30 18:53:02",
            "StoreCode" => "EZRBJ001",
            "ExchangeOriginalOrderCode" => "",
            "RefundPrepaidCardAmount" => 0,
            "RefundPrepaidCardGiftAmount" => 0,
            "OrderType" => "MALL",
            "OrderRefSuccessTime" => "",
            "RefRealStatus" => 0,
            "RefErrorMsg" => "",
            "RefFinalErrorMsg" => "",
            "RefLastModify" => "2024-05-30 18:53:02",
            "OutOrderCode" => "",
        ];

        return [
            'Status' => true,
            'StatusCode' => 200,
            'Sign' => 'XXXXXXXXXX',
            'Timestamp' => (string)time(),
            'Msg' => '成功',
            'Result' => $refund
        ];
    }

    public function morder_ordrefundgetbatch(Request $request)
    {
        $args = json_decode($request->get('Args'), true);
        $page = $args['PageIndex'] ?? 1;

        $refundSn1 = 'K630620240530000101';
        $orderSn1 = 'E6306202405300001';
        $returnSn1 = 'T630620240530000101';
        $itemTwoQty = true;

        $refund1 = [
            "RefundCode" => $refundSn1,
            "RefundStatus" => 1,
            //"RefundStatus" => 2,
            "OrderCode" => $orderSn1,
            "ReturnCode" => "",
            //"ReturnCode" => $returnSn1,
            "ShopCode" => $this->shopCode,
            "RefundTime" => "2024-05-30 18:50:28",
            "RefundMoney" => 100,
            "AmountMoney" => 100,
            "RefundReason" => "无理由退款",
            "BuyerCode" => "zh001ezr",
            "BuyerNick" => "zh",
            "BuyerOldCode" => "zh001oldezr",
            "BuyerName" => "张恒",
            "BuyerMobile" => "16601166306",
            "RecvConsignee" => "张恒",
            "RecvMobile" => "16601166306",
            "TradeNo" => "4200000001202405301850289001",
            "RefundRemark" => "退款吧",
            "FxHandler" => 1,
            "RefType" => 0,
            //"RefType" => 1,
            //"RefType" => 2,
            "ORfDtls" => [
                [
                    "OrderDtlId" => (int)(preg_replace("/[^0-9]/", '', $orderSn1) . '01'),
                    "BarCode" => "EZRMC00101",
                    "OrderQuantity" => $itemTwoQty ? 2 : 1,
                    "PriceOriginal" => 100,
                    "PriceSell" => 100,
                    "AvgAmount" => $itemTwoQty ? 200 : 100,
                    "ItemName" => "EZR男卫衣",
                    "OutOrderCode" => "",
                    "SkuAttrValsEx" => "",
                    "ReturnQuantity" => 1,
                    "ReturnMoney" => 100,
                    "AmountMenory" => 100,
                    "RefundRealAmountMoney" => 100,
                    "AttrInfos" => null,
                    "RefundRealUnitPrice" => 100,
                    "ItemNo" => "EZRMC001",
                    "ItemId" => 29001,
                    "SkuId" => 2900101,
                    "OutCode" => "EZRSKUA01",
                    "Quantity" => 1,
                    "RetailPrice" => 120,
                ],
            ],
            "LastModify" => "2024-05-30 18:53:02",
            "StoreCode" => "EZRBJ001",
            "ExchangeOriginalOrderCode" => "",
            "RefundPrepaidCardAmount" => 0,
            "RefundPrepaidCardGiftAmount" => 0,
            "OrderType" => "MALL",
            "OrderRefSuccessTime" => "",
            "RefRealStatus" => 0,
            "RefErrorMsg" => "",
            "RefFinalErrorMsg" => "",
            "RefLastModify" => "2024-05-30 18:53:02",
            "OutOrderCode" => "",
        ];

        $result = [];
        if ($page == 1) {
            $result[] = $refund1;
        }

        return [
            'Status' => true,
            'StatusCode' => 200,
            'Sign' => 'XXXXXXXXXX',
            'Timestamp' => (string)time(),
            'Msg' => '成功',
            'Result' => $result,
            'PageCount' => 1
        ];
    }

    public function morder_ordreturngetone(Request $request)
    {
        $args = json_decode($request->get('Args'), true);
        $reqReturnSn = $args['ReturnCode'] ?? '';

        $returnSn = 'T630620240530000101';
        $orderSn = 'E6306202405300001';
        $isExchangeReturn = false;

        if ($reqReturnSn != $returnSn) {
            return [
                'Status' => true,
                'StatusCode' => 200,
                'Sign' => 'XXXXXXXXXX',
                'Timestamp' => (string)time(),
                'Msg' => '成功',
                'Result' => []
            ];
        }

        $return = [
            "ReturnCode" => $returnSn,
            "OrderCode" => $orderSn,
            "OrderQty" => 2,
            "ShopCode" => $this->shopCode,
            "BuyerCode" => "zh001ezr",
            "ReturnTime" => "2024-05-30 18:40:28",
            "ReturnQty" => 1,
            "ReturnMoney" => 100,
            "ReturnReason" => "收到商品破损",
            "ReturnType" => 0,
            //"ReturnType" => 1,
            "ReturnStatus" => 1,
            //"ReturnStatus" => 3,
            //"ReturnStatus" => 4,
            //"ReturnStatus" => 5,
            //"ReturnStatus" => 6,
            "ComPostage" => 0,
            "ExpressCode" => "",
            //"ExpressCode" => "ZTO202405309001",
            "ExpressOrgCode" => "",
            //"ExpressOrgCode" => "ZTO",
            "ReturnRemark" => "",
            "ORtDtls" => [
                [
                    "BarCode" => $isExchangeReturn ? "EZRMC00103" : "EZRMC00101",
                    "OrderQuantity" => 1,
                    "ReturnQuantity" => 1,
                    "PriceOriginal" => 100,
                    "ReturnPrice" => 100,
                    "ReturnMoney" => 100,
                    "ReturnRewardFee" => 0,
                    "OutCode" => $isExchangeReturn ? "EZRSKUA03" : "EZRSKUA01",
                    "ItemNo" => "EZRMC001",
                    "OutOrderCode" => "",
                    "SkuAttrValsEx" => "",
                    "OrderDtlId" => (int)(preg_replace("/[^0-9]/", '', $orderSn) . ($isExchangeReturn ? '03' : '01')),
                ],
            ],
            "StoreCode" => "EZRBJ001",
            "ReturnWay" => 0,
            "BuyerOldCode" => "zh001oldezr",
            "BuyerMobile" => "16601166306",
            "BuyerNick" => "zh",
            "BuyerName" => "张恒",
            "RtLastModify" => "2024-05-30 18:43:02",
        ];

        return [
            'Status' => true,
            'StatusCode' => 200,
            'Sign' => 'XXXXXXXXXX',
            'Timestamp' => (string)time(),
            'Msg' => '成功',
            'Result' => $return
        ];
    }

    public function morder_ordreturngetbatch(Request $request)
    {
        $args = json_decode($request->get('Args'), true);
        $page = $args['PageIndex'] ?? 1;

        $returnSn1 = 'T630620240530000101';
        $orderSn1 = 'E6306202405300001';
        $isExchangeReturn = false;

        $return1 = [
            "ReturnCode" => $returnSn1,
            "OrderCode" => $orderSn1,
            "OrderQty" => 2,
            "ShopCode" => $this->shopCode,
            "BuyerCode" => "zh001ezr",
            "ReturnTime" => "2024-05-30 18:40:28",
            "ReturnQty" => 1,
            "ReturnMoney" => 100,
            "ReturnReason" => "收到商品破损",
            "ReturnType" => 0,
            //"ReturnType" => 1,
            //"ReturnStatus" => 1,
            "ReturnStatus" => 3,
            //"ReturnStatus" => 4,
            //"ReturnStatus" => 5,
            //"ReturnStatus" => 6,
            "ComPostage" => 0,
            "ExpressCode" => "",
            //"ExpressCode" => "ZTO202405309001",
            "ExpressOrgCode" => "",
            //"ExpressOrgCode" => "ZTO",
            "ReturnRemark" => "",
            "ORtDtls" => [
                [
                    "BarCode" => $isExchangeReturn ? "EZRMC00103" : "EZRMC00101",
                    "OrderQuantity" => 1,
                    "ReturnQuantity" => 1,
                    "PriceOriginal" => 100,
                    "ReturnPrice" => 100,
                    "ReturnMoney" => 100,
                    "ReturnRewardFee" => 0,
                    "OutCode" => $isExchangeReturn ? "EZRSKUA03" : "EZRSKUA01",
                    "ItemNo" => "EZRMC001",
                    "OutOrderCode" => "",
                    "SkuAttrValsEx" => "",
                    "OrderDtlId" => (int)(preg_replace("/[^0-9]/", '', $orderSn1) . ($isExchangeReturn ? '03' : '01')),
                ],
            ],
            "StoreCode" => "EZRBJ001",
            "ReturnWay" => 0,
            "BuyerOldCode" => "zh001oldezr",
            "BuyerMobile" => "16601166306",
            "BuyerNick" => "zh",
            "BuyerName" => "张恒",
            "RtLastModify" => "2024-05-30 18:43:02",
        ];

        $result = [];
        if ($page == 1) {
            $result[] = $return1;
        }

        return [
            'Status' => true,
            'StatusCode' => 200,
            'Sign' => 'XXXXXXXXXX',
            'Timestamp' => (string)time(),
            'Msg' => '成功',
            'Result' => $result,
            'PageCount' => 1
        ];
    }

    public function warehouse_stockupdate(Request $request)
    {
        $args = json_decode($request->get('Args'), true);
        $warehouseCode = $args['WarehouseCode'] ?? '';
        $barStocks = $args['BarStocks'] ?? [];
        $barStock = $barStocks[0];

        return [
            'Status' => true,
            'StatusCode' => 200,
            'Sign' => 'XXXXXXXXXX',
            'Timestamp' => (string)time(),
            'Msg' => '成功',
            'Result' => [
                'SuccessList' => [
                    [
                        'WareHouseCode' => $warehouseCode,
                        'BarCode' => $barStock['BarCode'],
                        'Stocks' => $barStock['Stocks']
                    ]
                ],
                'FailList' => [],
            ]
        ];
    }

    public function morder_ordsend(Request $request)
    {
        $args = json_decode($request->get('Args'), true);
        $orderSn = $args[0]['Code'] ?? '';
        $expressDtlList = $args[0]['ExpressDtlList'] ?? [];

        $result = [];
        foreach ($expressDtlList as $expressDtl) {
            $result[] = [
                'Code' => $orderSn,
                'BarCode' => $expressDtl['BarCode'],
                'ReturnCode' => 'SUCCESS',
                'ErroMsg' => ''
            ];
        }

        return [
            'Status' => true,
            'StatusCode' => 200,
            'Sign' => 'XXXXXXXXXX',
            'Timestamp' => (string)time(),
            'Msg' => '成功',
            'Result' => $result
        ];
    }

    public function morder_ordReturnStatus(Request $request)
    {
        $args = json_decode($request->get('Args'), true);

        return [
            'Status' => true,
            'StatusCode' => 200,
            'Sign' => 'XXXXXXXXXX',
            'Timestamp' => (string)time(),
            'Msg' => '成功',
            'Result' => 1
        ];
    }
}
